var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    dayStyle: [],
    userinfo:''
  },
  onLoad(){
    let that = this
    var timestamp = Date.parse(new Date());
    timestamp = timestamp / 1000;   
    console.log("当前时间戳为：" + timestamp); 
    wx.request({
      url: app.url + 'weiapp/api/getCalendar',
      data:{
        timestamp:timestamp,
        uid:wx.getStorageSync('uid')
      },
      success:function(res)
      {
        that.setData({
          dayStyle:res.data.data
        })
        console.log(that.data.dayStyle)
      }
    })
    wx.request({
      url:app.url + 'weiapp/api/userinfo',
      data:{
        uid:wx.getStorageSync('uid')
      },
      success:function(res){
        that.setData({
          userinfo: res.data.data
        })
        
      }
    })
  },
  nextMonthClick(even){
    let that = this
    wx.request({
      url: app.url + 'weiapp/api/getCalendar',
      data: {
        y:even.detail.currentYear,
        m:even.detail.currentMonth,
        uid: wx.getStorageSync('uid')
      },
      success: function (res) {
        that.setData({
          dayStyle: res.data.data
        })
        console.log(that.data.dayStyle)
      }
    })
    console.log(even)
  },
  prevMonthClick(even) {
    let that = this
    wx.request({
      url: app.url + 'weiapp/api/getCalendar',
      data: {
        y: even.detail.currentYear,
        m: even.detail.currentMonth,
        uid: wx.getStorageSync('uid')
      },
      success: function (res) {
        that.setData({
          dayStyle: res.data.data
        })
        console.log(that.data.dayStyle)
      }
    })
    console.log(even)
  }
})